package com.hzt.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 功能描述:
 * @author: huangzhitao
 * @date: 2021/3/20 8:34 上午
 */
@Configuration
public class ElasticClientConfig {

    @Bean
    public  RestHighLevelClient restHighLevelClient(){
        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("127.0.0.1", 9200, "http")
                        //集群配置多个，非集群配置一个
//                        ,new HttpHost("localhost", 9201, "http")
                ));
        return client;
    }

}